addNoDuplicates

fun <T> addNoDuplicates(list: MutableList<T>, candidate: T): Boolean

Add an item to a list, checking for duplicates. If the item is duplicated, it is not added and false is returned. This allows you to use a List container like a Set. There are situations where the List interface is more useful than the Set interface, but you cannot allow duplicates.

Return

True if the item was added, false if it already exists so it was not added again.

Parameters

list

The list to add the item to.

candidate

The candidate item.

The type of object contained by `list`.